
var tab = document.getElementById("tab");
var lbl = document.getElementById("lblSelectedRow");
if(lbl)
lbl.innerHTML="<input name='checkedCountInput' type='text' readonly='true' style='border:0;width:20px'/>";
var checkedCountObj = $$("checkedCountInput");
var rows = tab.rows;
rows[0].className = "ListTableHeader";
for (i = 1; i < rows.length; i++) {
	var row = (typeof rows[i] != undefined) ? rows[i] : null;
	var rowIndex = row.rowIndex;
	var rowin = parseInt(rowIndex) - 1;
	if (rowin % 2 == 0) {
					row.className = "ListTableOddRow";
				}else {
					row.className = "ListTableEvenRow";
				}
	if (rowin % 2 == 0) {
		row.onmouseout = function () {
			this.className = "ListTableOddRow";
		};
	} else {
		row.onmouseout = function () {
			this.className = "ListTableEvenRow";
		};
	}
}
for (i = 1; i < rows.length; i++) {
	rows[i].onmouseover = function () {
		this.className = "ListTableHoverRow";
	};
}
var checkedCount = 0;
rows[0].className="ListTableHeader";
rows[0].cells[0].childNodes[0].onclick=function(){
	for(var i=1;i<rows.length;i++){
		rows[i].cells[0].childNodes[0].checked=this.checked;
	}
	if(checkedCountObj) checkedCountObj.value = (this.checked?rows.length-1:0)+"";
};

for (i = 1; checkedCountObj && i < rows.length; i++) {
	var checkObj = rows[i].cells[0].childNodes[0];
	if(checkObj.checked) checkedCount++;
	if(i==rows.length-1) checkedCountObj.value = checkedCount+"";
	rows[i].onclick = function () {
		this.className = "ListTableSelectedRow";
		var ct = parseInt(checkedCountObj.value);
		this.childNodes[0].childNodes[0].checked = !this.childNodes[0].childNodes[0].checked;
		checkedCountObj.value = this.childNodes[0].childNodes[0].checked?ct+1:ct-1;
	};
}

